import { createRouter, createWebHistory } from "vue-router";
import Layout from "@/layout/Index.vue"; // 刚建的 Layout
import constantRouterMap from "./routerMap";

/* 把 constantRouterMap 塞进 Layout 的 children 里 */
const routes = [
  /* 登录页 —— 不经过 Layout，也不进菜单 */
  {
    path: "/login",
    name: "login",
    component: () => import("@/views/login/Index.vue"),
  },

  /* 业务页面 —— 统一走 Layout，并自动生成菜单 */
  {
    path: "/",
    component: Layout,
    redirect: "/home",
    children: constantRouterMap, // 只放首页、系统管理等
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

export default router;
